import json

from dotenv import load_dotenv
from openai import OpenAI

from langchaindemo.openai.tools import tools

# 加载 .env 文件中的环境变量
load_dotenv()

client = OpenAI()

messages = []
messages.append({"role": "system",
                 "content": "Don't make assumptions about what values to plug into functions. Ask for clarification if a user request is ambiguous."})
messages.append({"role": "user", "content": "What's the weather like today in London"})
chat_response = client.chat.completions.create(
    model='gpt-3.5-turbo-0613',
    messages=messages,
    tools=tools
)
assistant_message = chat_response.choices[0].message
print("assistant: ", assistant_message.content)
print("assistant.function_call: ", assistant_message.tool_calls[0].function)

